//
//  RACRequest.m
//  BigJoy
//
//  Created by Rowling on 2017/7/3.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "RACRequest.h"

@implementation RACRequest
+(instancetype)shareInstance {
   static RACRequest * manage;
    if (manage == nil) {
        manage = [[RACRequest alloc]init];
    }
    return manage;
}

-(RACCommand *)getMessageCommand {
    if (_getMessageCommand == nil) {
        _getMessageCommand = [[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
            return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
                [WYNetTool GET_Urlstring:sendMessageUrl parameters:input success:^(id responseObject) {
                    [subscriber sendNext:responseObject];
                    [subscriber sendCompleted];
                } fail:^(id error) {
                    [subscriber sendError:error];
                }];
                return nil;
            }];
        }];
    }
    return _getMessageCommand;
}

-(RACCommand *)verifyCoedCommand {
    if (_verifyCoedCommand == nil) {
        _verifyCoedCommand = [[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
            return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
                [WYNetTool GET_Urlstring:sendMessageUrl parameters:input success:^(id responseObject) {
                    [subscriber sendNext:responseObject];
                    [subscriber sendCompleted];
                } fail:^(id error) {
                    [subscriber sendError:error];
                }];
                return nil;
            }];
        }];
    }
    return _verifyCoedCommand;
}

+(RACCommand *)getMessageCommand {
     RACCommand * command = [[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
            return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
                [WYNetTool GET_Urlstring:sendMessageUrl parameters:input success:^(id responseObject) {
                    [subscriber sendNext:responseObject];
                    [subscriber sendCompleted];
                } fail:^(id error) {
                    [subscriber sendError:error];
                }];
//                [WYNetTool POST_Urlstring:sendMessageUrl parameters:input success:^(id responseObject) {
//                    [subscriber sendNext:responseObject];
//                    [subscriber sendCompleted];
//                } fail:^(id error) {
//                    [subscriber sendError:error];
//                }];
                return nil;
            }];
        }];
    return command;
}

+(RACCommand *)verifyCoedCommand {
    RACCommand * command = [[RACCommand alloc]initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
        return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
            [WYNetTool GET_Urlstring:VerifyPhoneUrl parameters:input success:^(id responseObject) {
                [subscriber sendNext:responseObject];
                [subscriber sendCompleted];
            } fail:^(id error) {
                [subscriber sendError:error];
            }];
            return nil;
        }];
    }];
    return command;
}



@end
